# arr = [4,3,2,1,0]
# arr = [1,2,0,4,5,3,6,7]
arr=[1,0,2,3,4]
def maxChunksToSorted(arr):
    state=[False for _ in range(len(arr))]
    curMin=0
    curMax=-1
    index=0
    count=0
    while index<len(arr):
        cur=arr[index]
        state[cur]=True
        if cur>curMax:
            curMax=cur
        # if curMin==curMax:
        #     print(curMin,curMax)
        #     count+=1
        if cur==curMin:
            for s in range(len(state)):
                if state[s]==False:
                    curMin=s
                    break
            if curMin>curMax:
                count+=1
        index+=1
    print(count+1)
    print(state)
maxChunksToSorted(arr)